﻿using System;
using System.Diagnostics;

namespace Skynet.CommonLibrary.Extension
{
    public static  class ProcessExtension
    {
        public static void StartProcessEx(this string exeName, string arguments, string workingDirectory)
        {
            //声明一个程序信息类
            ProcessStartInfo info = new ProcessStartInfo
                                        {
                                            //设置外部程序名
                                            FileName = exeName,
                                            //设置外部程序的启动参数（命令行参数）为test.txt
                                            Arguments = arguments,
                                            //设置外部程序工作目录为  C:\
                                            WorkingDirectory = workingDirectory
                                        };

            try
            {
                //
                //启动外部程序
                //
                Process.Start(info);
            }
            catch (System.ComponentModel.Win32Exception e)
            {
                throw new Exception("系统找不到指定的程序文件。\r{0}", e);
            }
        }
    }
}
